<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <!-- <div id="app">
        <button v-on:click='num++'>点击1</button>
        <br>
        <span>{{num}}</span> -->

    <!-- <button v-on:click='add'>点击</button> -->
    <!-- 简写   v-on:  @ -->
    <!-- <button @click='add'>点击2</button> -->

    <!-- <button @click='add()'>点击3</button> -->

    <!-- <button @click='getVal'>获取值</button>

        <button @click='getValParams(1,2)'>传递参数</button>

        <button @click='getValParams(1,2,$event)'>传递参数 并且获取值</button>
    </div>

    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                num: 10
            },
            methods: {
                // add: function() {
                //     alert(this.num);
                //     this.num += 1;
                // }

                add() {
                    this.num += 1;
                },

                getVal(e) {
                    console.log(e.target.innerHTML);
                },
                getValParams(a, b, e) {
                    this.num = a + b;
                    console.log(e.target.innerHTML);
                }
            }
        })
    </script> -->
































    <div id="app">
        <button v-on:click="num++">点击1</button>
        <br>
        <span>{{num}}</span>

        <button @click='add'>点击2</button>

        <button @click='getVal'>获取值</button>

        <button @click='getValParams(1,2)'>传递参数</button>

        <button @click='getValParams(1,2,$event)'>传递参数 并且获取值</button>
    </div>

    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                num: 10
            },
            methods: {
                add() {
                    this.num += 1;
                },

                getVal(e) {
                    console.log(e.target.innerHTML);
                },

                getValParams(a, b, e) {
                    this.num = a + b;
                    console.log(e.target.innerHTML);
                }
            }
        })
    </script>
</body>

</html>